const app = getApp();
const db = wx.cloud.database();
function eduosLg(xh, pwd) {
  if (typeof xh == 'undefined' || typeof pwd == 'undefined') {
    console.log('..数据未定义,查询缓存数据')
  } else {
    var url = app.eduOS.sdust + 'method=authUser&xh=' + xh + '&pwd=' + pwd;
  }
  return url;
};
function vcode(date) {
  var year = date.getFullYear()
  var month = date.getMonth() + 1
  var day = date.getDate()

  var hour = date.getHours()
  var minute = date.getMinutes()
  var second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('_') + '_' + [hour, minute, second].map(formatNumber).join('_')
};
function formatNumber(n) {
  n = n.toString()
  return n[1] ? n : '0' + n
};
function getformatTime(date) {
  var year = date.getFullYear()
  var month = date.getMonth() + 1
  var day = date.getDate()

  var hour = date.getHours()
  var minute = date.getMinutes()
  var second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('-');
};
function eduosEmpclass(mydate,myjxlid){
  var url = app.eduOS.sdust + 'method=getKxJscx&time=' +this.getformatTime(new Date())+'&idleTime='+mydate+'&jxlid='+myjxlid;
  console.log(url);
  return url;

};
function getTime(){
  var url = app.eduOS.sdust + 'method=getCurrentTime&currDate=' + getformatTime(new Date());
  return url;
};
function eduClass(xh,xnxq,zc){
  //还是要进行
  if(typeof xnxq == 'undefined' || typeof zc == 'undefined'){console.log('..数据不完全')}else{
    var url = app.eduOS.sdust + 'method=getKbcxAzc&xh='+xh +'&xnxqid='+xnxq +'&zc=' + zc;  
  }
   return url;
};
function eduGrade(xh,xnxq){
  if(typeof xnxq == 'undefined'){
    //查询全部成绩
    var url = app.eduOS.sdust + 'method=getCjcx&xh='+xh;
  }
  else{
    var url = app.eduOS.sdust + 'method=getCjcx&xh='+xh+'&xnxqid='+xnxq;
  }
  return url;
  
};
function formatTime(date) {
  var year = date.getFullYear()
  var month = date.getMonth() + 1
  var day = date.getDate()

  var hour = date.getHours()
  var minute = date.getMinutes()
  var second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
};
function xhinfo(xh){
  var url = app.eduOS.sdust + 'method=getUserInfo&xh='+xh;
  return url;
};
module.exports = {
  eduoslg: eduosLg,
  eduosEmpclass: eduosEmpclass,
  getformatTime: getformatTime,
  eduClass: eduClass,
  getTime: getTime,
  eduGrade: eduGrade,
  vcode: vcode,
  formatTime: formatTime,
  xhinfo: xhinfo
}